package com.future.taskdemo.CompletionStage;

import java.util.HashMap;
import java.util.Map;

public class Test {

    public static void main(String[] args) {

        String str = "name:测试|queue:PUSH_QUEUE|sql:SELECT * FROM sdyc_cons_tg_info where shard_no=?|clear:true|bigkey:TE|key:mped_id|val:mped_id";
        Map<String, String> stringStringMap = fullMaps(str, new HashMap<>());
        System.out.println(stringStringMap);

    }

    private static Map<String, String> fullMaps(String strings, Map<String, String> map) {
        int i = strings.indexOf("|");
        String substring;
        if ("".equals(strings) || !strings.contains(":")) {
            return map;
        }

        if (i != -1) {
            substring = strings.substring(0, i);
            String[] split = substring.split(":");
            map.put(split[0], split[1]);
            return fullMaps(strings.substring(i + 1), map);
        } else {
            String[] split = strings.split(":");
            map.put(split[0], split[1]);
            return map;
        }
    }
}
